package cn.lingyangwl.agile.gateway;

import cn.lingyangwl.agile.gateway.config.MyGatewayProperties;
import cn.lingyangwl.agile.gateway.config.UploadFileProperties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.stream.Collectors;

/**
 * @author shenguangyang
 */
@Configuration
@EnableAsync
@EnableConfigurationProperties({MyGatewayProperties.class, UploadFileProperties.class})
public class GatewayMainConfig {
    @Bean
    @ConditionalOnMissingBean
    public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {
        return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));
    }

}
